import QtQuick 2.15
import QtQuick.Controls 2.15
import "../theme"

Button {
    id: control
    
    property bool plain: false
    property string type: "default" // primary, success, warning, danger, info
    
    height: 40
    padding: 12
    
    contentItem: Text {
        text: control.text
        font.pixelSize: 14
        color: plain ? getTypeColor() : (type === "default" ? "#606266" : "#FFFFFF")
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter
    }
    
    background: Rectangle {
        radius: 4
        color: plain ? "transparent" : getTypeColor()
        border.color: getTypeColor()
        border.width: plain ? 1 : 0
        
        Behavior on color {
            ColorAnimation { duration: 150 }
        }
    }
    
    function getTypeColor() {
        switch(type) {
            case "primary": return Theme.primary
            case "success": return Theme.success
            case "warning": return Theme.warning
            case "danger": return Theme.danger
            case "info": return Theme.info
            default: return Theme.borderBase
        }
    }
} 